package com.peak.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Map;

@Service
@Slf4j
public class TestService {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 请求转发MQ，削峰
     * @param exchange
     * @param key
     * @param params
     */
    public void convertAndSend(String  exchange ,String key ,Map<String, Object> params){
        rabbitTemplate.convertAndSend(exchange, key, params);
    }
    /**
     * 业务处理方法
     */
    public void business(Map<String, Object> params){
        //你的实际业务代码块
        try {
            String id = (String)params.get("id");
            log.info("获取到的参数："+id);
            Thread.sleep(200);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
